package com.chenbei.erp.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chenbei.common.annotation.DomainUrl;
import com.chenbei.common.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("erp_product")
@Schema(description = "产品")
public class Product extends BaseEntity {

    @Schema(description = "主键ID")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "产品编号")
    private String code;

    @Schema(description = "名称")
    @NotBlank(message = "产品名不能为空")
    @TableField("name")
    private String name;

    @Schema(description = "分类ID")
    @TableField("category_id")
    private Long categoryId;

    @Schema(description = "分类名称")
    @TableField(exist = false)
    private String categoryName;

    @Schema(description = "品牌ID")
    private Long brandId;

    @Schema(description = "品牌名称")
    @TableField(exist = false)
    private String brandName;

    @Schema(description = "图片")
    @TableField("image")
    @DomainUrl
    private String image;

    @Schema(description = "规格型号")
    @TableField("specifications")
    private String specifications;

    @Schema(description = "描述")
    @TableField("description")
    private String description;

    @Schema(description = "单位ID")
    @TableField("unit_id")
    private Long unitId;

    @Schema(description = "单位名称")
    @TableField(exist = false)
    private String unitName;

    @Schema(description = "安全库存量")
    @TableField("safe_stock_quantity")
    private Integer safeStockQuantity;

    @Schema(description = "状态[1:上架|2:下架]")
    @TableField("status")
    private Integer status;

    @Schema(description = "成本售价/元")
    @TableField("cost_price")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal costPrice;

    @Schema(description = "标准售价/元")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal sellingPrice;

    @Schema(description = "进项税率(%)")
    @TableField("input_tax_rate")
    private Integer inputTaxRate;

    @Schema(description = "销项税率(%)")
    @TableField("output_tax_rate")
    private Integer outputTaxRate;
}
